{include file="public/nheader" /}
<style type="text/css">
    #lay-tableList {
        height: auto;
    }

    .layui-table-view .layui-table[lay-size=lg] .layui-table-cell {
        height: auto;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div class="layui-card-header layadmin-card-header-auto ">
            <div class="layui-form">
                <div class="layui-form-item">
                    <!-- <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="province" lay-filter="province">
                                <option value="">请选择搜索省份</option>
                                {foreach $province as $v}
                                <option value="{$v.area_code}" {if !empty(input('get.province')) &&
                                    input('get.province')==$v.area_code}selected{/if}>{$v.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="city" lay-filter="city">
                                <option value="">请选择搜索城市</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="area" lay-filter="area">
                                <option value="">请选择搜索区域</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="street" lay-filter="street">
                                <option value="">请选择搜索街道</option>
                            </select>
                        </div>
                    </div> -->
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <input name="title" class="layui-input" type="text" placeholder="用户名|身份证|手机号" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <!-- // 默认搜索 -->
                        <input name="rider" type="hidden" value="{:input('get.rider')}" />
                        <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit>搜索</button>
                        <!-- // 打开添加页面 -->
                        <button class="layui-btn icon-btn" lay-maxmin="true" lay-open="" data-title="添加"
                            data-area="60%,80%" data-url="/agent/riderstreet_edit?riderid={:input('rider/d',0)}">单个添加
                        </button>
                        <!-- <button class="layui-btn icon-btn" lay-maxmin="true" lay-open="" data-title="添加"
                            data-area="60%,80%" data-url="/agent/riderstreet_edit2?riderid={:input('rider/d',0)}">批量添加
                        </button> -->
                        <!-- // 删除所有 -->
                        <button class="layui-btn icon-btn layui-btn-danger" lay-batch="lay-tableList"
                            data-url="/agent/riderstreet_del">批量删除
                        </button>
                    </div>
                </div>
            </div>
        </div>

        <!-- // 创建数据实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>
    </div>
</div>
<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar">
    <div class="layui-divider layui-divider-vertical"></div>
    {{#  if(d.status ==1){ }}
    <a class="layui-table-text" data-url="/agent/riderstreet_status?id={{d.id}}&status=2&field=status" data-reload="self" data-confirm="" lay-ajax="">通过</a>
    <div class="layui-divider layui-divider-vertical"></div>
    {{#  if(d.pid == 0){ }}
    //<a class="layui-table-text" onclick="delAll('/agent/riderstreet_status', '{{d.id}}')">设置团队长并通过</a>
    //<br/>
    {{#  } }}
    <a class="layui-table-text" data-url="/agent/riderstreet_status?id={{d.id}}&status=3&field=status" lay-event="del">驳回</a>
    <div class="layui-divider layui-divider-vertical"></div>
    {{#  } }}
    <a class="layui-table-text" data-url="/agent/riderstreet_del?id={{d.id}}" lay-event="del">删除</a>
</script>
{include file="public/nfooter"}
<script>
    function delAll(url, id) {
        var ids = id;
        layer.prompt({ title: '填写团队长师傅账号,并确保账号已设置为团队长' }, function (value, index, elem) {
            //捉到所有被选中的，发异步进行删除
            $.post(url, { id: ids, value: value, status: 2, field: 'status', sz: 1 },
                function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, function () {
                            // 获得frame索引
                            location.reload();
                            layer.close();
                        });
                    } else {
                        layer.msg(data.msg, 'error');
                    }
                }, "json"
            ).error(function () {
                layer.msg('请求错误,请重试', 'error');
            });
        });
    }
    layui.use(['table'], function () {

        var table = layui.table;        // 表格
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList",
            where: {
                rider: "{:input('rider/d',0)}"
            }
            , url: "{:url()}"
            , page: true
            , size: 'lg'
            , even: true
            , cols: [[
                { type: 'checkbox', width: 60 },
                { field: 'id', align: 'center', sort: true, width: 80, title: 'ID' },
                {
                    field: 'status', align: 'center', width: 120, templet: function (d) {
                        var text = '';
                        if (d.status == 1) {
                            text = '<span class="layui-badge layui-bg-blue">待审核</span>';
                        }
                        if (d.status == 2) {
                            text = '<span class="layui-badge layui-bg-orange">通过</span>';
                        }
                        if (d.status == 3) {
                            text = '<span class="layui-badge layui-bg-green">驳回</span>';
                        }
                        return text;

                    }, title: '状态'
                },
                //                { field: 'area_text', align: 'center', width: 100, title: '区' },
                //              { field: 'street_text', align: 'center', width: 100, title: '街道' },
                {
                    field: 'name', align: 'center', width: 200, title: '名称/身份证/账号', templet: function (d) {
                        return d.name + '<br/>' + d.cards + '<br/>' + d.mobile;
                    }
                },
                {
                    field: 'positive', align: 'center', width: 200, templet: function (d) {
                        var text = d.positive ? '<div><img style="width:50px" src="' + d.positive + '"lay-image-click=""></div>' : '<div></div>';
                        var text2 = d.negative ? '<div><img style="width:50px" src="' + d.negative + '"lay-image-click=""></div>' : '<div></div>';
                        return text + text2;
                    }, title: '身份证图片'
                }, { field: 'created', width: 200, align: 'center', title: '申请时间' },
                { align: 'center', toolbar: '#tableBar', width: 250, title: '操作' },
            ]]
        })
    })
</script>
</body>